using System.Linq;
using VirtualDeveloper.Filters;
using Xunit;

namespace UnitTest
{
    public class RoundRobinEnumerableTest
    {
        [Fact]
        public void Return_first_element()
        {
            var roundRobin = new RoundRobinEnumerable<string>(new[] { "hello", "pouet" });

            Assert.Equal<string>("hello", roundRobin.First());
        }

        [Fact]
        public void Round_robin()
        {
            var strings = new[] { "hello", "pouet" };
            const int counter = 10;
            var roundRobin = new RoundRobinEnumerable<string>(strings).Take(counter).ToList();

            for (var i = 0; i < counter; i++)
            {
                var actual = roundRobin[i];
                if (i % 2 == 0)
                {
                    Assert.Equal<string>(strings[0], actual);
                }
                else
                {
                    Assert.Equal<string>(strings[1], actual);
                }
            }
        }
    }
}